/*
 * @Description: 页面配置
 * @Author: Liu Zhiwang
 * @Date: 2021-03-27 14:34:23
 * @LastEditTime: 2021-04-26 12:00:38
 * @LastEditors: Liu Zhiwang
 */
import variables from '@/styles/element-variables.scss'
import defaultSettings from '@/settings'

const { showSettings, tagsView, fixedHeader, sidebarLogo } = defaultSettings

const state = {
  theme: variables.theme,
  showSettings: showSettings,
  tagsView: tagsView,
  fixedHeader: fixedHeader,
  sidebarLogo: sidebarLogo,
  pageZoom: document.body.clientWidth / 1920 // 页面缩放设置值
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  },
  // 更改页面缩放设置值
  PAGE_ZOOM_SETTING: (state, { key, value }) => {
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  },
  changePageZoom({ commit }, data) {
    commit('PAGE_ZOOM_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

